package com.clstu.method;

public class ThreadMethodExercise {
    public static void main(String[] args) throws InterruptedException {
        Hi hi = new Hi();
        for (int i = 0; i < 10; i++) {
            System.out.println("hello ~~~~~~~~~"+i);
            Thread.sleep(200);
            if(i==5) {
                hi.start();
                hi.join();
            }
        }

    }
}
class Hi extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println("h~~~~~~~~~~~"+i);
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
